<?php
/**
 *
 * @author Strawberry🍓
 * @date 2021-05-21 4:08 下午
 *
 */

namespace app\common\model\tang;


use app\common\impl\Comm;
use app\common\model\CommonBaseModel;

class ReleaseUser extends CommonBaseModel implements Comm
{

    public function getAdminPageData($param = [], $order = 'id desc',$where=[])
    {
        $model = self::where($where);
        // TODO: Implement getAdminPageData() method.
        if(isset($param['username'])&&!empty($param['username'])){
            $where[] = ['name|mobile','like',"%{$param['username']}%"];
        }
        $data = $model->where($where)->order($order)->page(PAGE)->limit(LIMIT)->select()->toArray();
        $count = $model->count("id");

        return parent::ajaxResult($data, $count);
    }

    public function delById($ids)
    {
//        // TODO: Implement delById() method.
//        $result = self::update([
//            'status'=> -1
//        ],['id'=>$id]);

        try {
            if (is_array($ids)){
                $id=$ids;
            }else{
                $id=@explode(",",$ids);
            }
            $result = self::where('id', 'in',$id)->update(['status'=> -1]);
//            $result = self::where('id', 'in',$id)->delete();
//        $result = self::update([
//            'status'=> -1
//        ],['id'=>$id]);
            if ($result) {
                return self::JsonReturn("删除成功");
            } else {
                return self::JsonReturn("删除失败",0);
            }
        } catch (\Exception $exception) {
            return self::JsonReturn($exception->getMessage(),0);
        }
    }
    public function doAll($data)
    {
        // TODO: Implement doAll() method.
        return parent::doAllData($data);
    }
}